package org.jet.emall.rbac.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jet.emall.common.restful.result.CommonResult;
import org.jet.emall.rbac.annotation.ApiInformation;
import org.jet.emall.rbac.dto.AdminPrivilegeDTO;
import org.jet.emall.rbac.service.CustomAdminPrivilegeService;
import org.jet.emall.rbac.transfer.AdminPrivilegeVoTransfer;
import org.jet.emall.rbac.vo.AdminPrivilegeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xiaozai
 * @version 1.0
 * @date 2020-04-10 13:20
 */
@Api(value = "权限管理控制器")
@RestController
public class AdminPrivilegeController {


    @Autowired
    private CustomAdminPrivilegeService customAdminPrivilegeService;

    @ApiInformation(function = "获取权限列表",menu = "权限管理")
    @ApiOperation("获取权限列表")
    @RequestMapping(value = "/privileges",method = RequestMethod.GET)
    public CommonResult<List<AdminPrivilegeVO>> list(){
        List<AdminPrivilegeDTO> adminPrivilegeDTOList =  customAdminPrivilegeService.list();
        List<AdminPrivilegeVO> adminPrivilegeVOList = AdminPrivilegeVoTransfer.INSTANCE.toVoList(adminPrivilegeDTOList);
        return CommonResult.success(adminPrivilegeVOList,"获取权限列表成功");
    }
}
